package com.example.lib_image

import android.graphics.Typeface
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.load.resource.bitmap.CircleCrop

object ImageBindingAdapter {
    @JvmStatic
    @BindingAdapter("avatarUrl")
    fun avatarUrl(imageView: ImageView, url: String?){
        GlideApp.with(imageView.context)
            .load(url)
            .transform(CircleCrop())
            .placeholder(R.mipmap.icon_default_avatar)
            .error(R.mipmap.icon_default_avatar)
            .into(imageView)
    }
    @JvmStatic
    @BindingAdapter("textBold")
    fun textBold(textView: TextView, boolean: Boolean) {
        textView.typeface = if (boolean) Typeface.DEFAULT_BOLD else Typeface.DEFAULT
    }
}